package org.fast.develop.logicflow.rest.dto;

import lombok.Data;
import lombok.experimental.Accessors;
import org.fast.develop.logicflow.runtime.monitor.ExecuteLog;

import java.util.List;
import java.util.Map;
import java.util.Objects;

/**
 * @author czh
 * @version V1.0
 * @data Created on 2023-01-04 10:08
 */
@Data
@Accessors(chain = true)
public class TestModelResDto {

    private Map map;

    private Map result;

    private List<ExecuteLog> logsObj;

    private String logs;

    public String getLogs() {
        if (Objects.nonNull(logsObj)) {
            StringBuilder logsBuilder = new StringBuilder();
            logsObj.forEach(item -> {
                logsBuilder.append(item.getMsg() + "\n");
            });
            return logsBuilder.toString().trim();
        } else {
            return logs;
        }
    }

    public void addLog(String log){
        this.logs = this.logs.concat(log);
    }
}
